
import API from '../../API/list.js'

export default {
  data() {
    return {
      openType: '',
      API: API,
    }
  },
  methods: {
    /**
     * @description:初始化
     * @param {*} one 详情数据
     * @param {*} openType 弹窗名称
     * @return {*}
     */
    init(one, openType) {
      this.dialogVisible = true
      this.one = one
      this.openType = openType
    },
    formatterTime(prop, row) {
      if (row[prop]) {
        return this.CORE.timeStr(row[prop])
      } else {
        return '--'
      }
    },
    /**
     * 打开误报消除弹窗
     *
     * @param {*} row
     * @param {*} openType
     * @param {*} refName
     */
    openModel(row, openType, refName = 'formModal') {
      this.$nextTick(() => {
        this.$refs[refName].init(row, openType)
      })
    },
    async deal(row, type) {
      row.dealType = type
      try {
        await this.API.update(row)
        this.$message.success('操作成功')
        this.one.dealType = type
      } catch (error) {
        error && this.$message.error(error.message)
      }
    },
    refreshDealType(one) {
      this.one = one
      this.$emit('refreshDataList')
    },
  },
}
